home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / Jun 90 / MacApp.Tech$ 6⁄1⁄90 / 1389-Complete Focus Fix (-May90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  2.8 KB  |  77 lines  |  [TEXT/GEOL]

  1. Item    6173538                         31-May-90        14:00PDT
  2.  
  3. From:   D4695                           Skywalker Sys, Scott Collins,PRT
  4.  
  5. To:     MOOF                            Rollin, Keith A
  6.         MACAPP.TECH$                    MacApp Technical
  7.         MACDTS                          Macintosh Developer Tech Supt
  8.  
  9. Sub:    Complete Focus Fix (+new bug)
  10.  
  11. Hello,
  12.  
  13.     This is an update to the Focus and IsShown bugs I posted recently.  First,
  14. the recursive version of TView.IsShown works well and as yet no bad side
  15. effects have surfaced.  Second, the modification to TControl.ContainsMouse does
  16. have a bad side effect caused by an inconsistancy in MacApp.  TCtlMgr objects
  17. neither use, nor respect the fShown field.  Instead they use the routines
  18. SetCMgrVisibility and IsCMgrVisible.  It seems that fShown is typically FALSE
  19. for such an object, even when it is visible, thus it would fail the
  20. TControl.ContainsMouse test.  (So after installing the new
  21. TControl.ContainsMouse, none of your scrollbars, for instance, would accept
  22. mouse clicks anymore.)
  23.  
  24.     One way to fix this problem would be to write a TCtlMgr.Show that did the
  25. right thing and use it instead (of SetCMgrVisibility), but after examining how
  26. MacApp uses SetCMgrVisibility, I found that this would be a difficult
  27. proposition.  If the MacApp team wants to enforce consistant use of fShown,
  28. they can do it; the easy thing for me to do was allow TCtlMgr's to have their
  29. own way of determining visibility.  To reflect this I had to write
  30. TCtlMgr.IsShown.
  31.  
  32.     Here are the one new and two modified routines I am now using (so far with
  33. great success).  Some of the bugs they fix are: 1) invisible controls in
  34. dialogs accepting mousedowns and doing things; 2) children of invisible
  35. controls being asked to draw or handle a mousedown; 3) scrollbars of hidden
  36. scrollers appearing; 4) your calls to IsShown for an arbitrary view returning
  37. untrue (true) results.
  38.  
  39. { -------------------------------------------------- }
  40. FUNCTION TView.IsShown: BOOLEAN;
  41.     BEGIN
  42.     IsShown := fShown;
  43.     IF fShown & (fSuperView<>NIL) THEN
  44.         IsShown := fSuperView.IsShown;
  45.     END;
  46.  
  47. { -------------------------------------------------- }
  48. FUNCTION TControl.ContainsMouse(theMouse: VPoint): BOOLEAN; OVERRIDE;
  49.         VAR
  50.             aRect: Rect;
  51.     BEGIN
  52.     IF IsShown THEN
  53.         BEGIN
  54.         ControlArea(aRect);
  55.         ContainsMouse := PtInRect(VPtToPt(theMouse), aRect);
  56.         END
  57.     ELSE
  58.         ContainsMouse := FALSE;
  59.     END;
  60.  
  61. { -------------------------------------------------- }
  62. FUNCTION TCtlMgr.IsShown: BOOLEAN;
  63.         VAR
  64.             shown: Boolean;
  65.     BEGIN
  66.     shown := IsCMgrVisible;
  67.     IF fSuperView <> NIL THEN
  68.         shown := shown & fSuperView.IsShown;
  69.     IsShown := shown;
  70.     END;
  71.  
  72.  
  73.  
  74.     Hope this helps (and thanks Keith)
  75.     -- Scott Collins
  76.  
  77.